/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package onpu_dms_xls.kernel.common;

/**
 *
 * @author snbm
 */
public class VariableDeclaration {

    private String varName;
    private boolean isInIteration;
    private VariableDataTypes dataType;
    private VariableType varType;
    private String fromDBQuery;
    private String toDBQuery;
    private String value; //for a 0 level variable, get the value from input
                          //and for higher level variables to pass it's value
    //is used in iteration row, this parameter is set for all iteration variables
    private String iterationRowSingleFromDBQuery;
    
    private String defaultValue;
    private boolean valueSet;

    public VariableDeclaration() {
        this.valueSet = false;
    }

    public VariableDeclaration(String varName, boolean isInIteration, VariableDataTypes dataType, VariableType varType, String fromDBQuery, String toDBQuery) {
        this.varName = varName;
        this.isInIteration = isInIteration;
        this.dataType = dataType;
        this.varType = varType;
        this.fromDBQuery = fromDBQuery;
        this.toDBQuery = toDBQuery;
        this.valueSet = false;
    }

    /**
     * method equals compares only String varName fields of classes
     */
    @Override
    public boolean equals(Object o) {
        boolean res = false;

        if (!(o instanceof VariableDeclaration)) {
            return res;
        }

        VariableDeclaration temp = (VariableDeclaration) o;
        if (this.getVarName().equals(temp.getVarName())) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public String toString() {
        if (!this.isInIteration()) {
            return "variable: " + this.getVarName()
                    + "\n\tvarType=" + this.getVarType()
                    + "\n\tdataType=" + this.getDataType()
                    + "\n\tisIteration=" + this.isInIteration()
                    + "\n\tfromDBQuery=" + this.getFromDBQuery()
                    + "\n\ttoDBQuery=" + this.getToDBQuery()
                    + "\n\tvalue=" + this.getValue();
        } else {
            return "variable: " + this.getVarName()
                    + "\n\tvarType=" + this.getVarType()
                    + "\n\tdataType=" + this.getDataType()
                    + "\n\tisIteration=" + this.isInIteration()
                    + "\n\tfromDBQuery=" + this.getFromDBQuery()
                    + "\n\ttoDBQuery=" + this.getToDBQuery()
                    + "\n\titerationRowSingleFromDBQuery=" + this.getIterationRowSingleFromDBQuery()
                    + "\n\tvalue=" + this.getValue();
            
        }

    }

    /**
     * @return the varName
     */
    public String getVarName() {
        return varName;
    }

    /**
     * @param varName the varName to set
     */
    public void setVarName(String varName) {
        this.varName = varName;
    }

    /**
     * @return the isInIteration
     */
    public boolean isInIteration() {
        return isInIteration;
    }

    /**
     * @param isInIteration the isInIteration to set
     */
    public void setIsInIteration(boolean isInIteration) {
        this.isInIteration = isInIteration;
    }

    /**
     * @return the dataType
     */
    public VariableDataTypes getDataType() {
        return dataType;
    }

    /**
     * @param dataType the dataType to set
     */
    public void setDataType(VariableDataTypes dataType) {
        this.dataType = dataType;
    }

    /**
     * @return the varType
     */
    public VariableType getVarType() {
        return varType;
    }

    /**
     * @param varType the varType to set
     */
    public void setVarType(VariableType varType) {
        this.varType = varType;
    }

    /**
     * @return the fromDBQuery
     */
    public String getFromDBQuery() {
        return fromDBQuery;
    }

    /**
     * @param fromDBQuery the fromDBQuery to set
     */
    public void setFromDBQuery(String fromDBQuery) {
        this.fromDBQuery = fromDBQuery;
    }

    /**
     * @return the toDBQuery
     */
    public String getToDBQuery() {
        return toDBQuery;
    }

    /**
     * @param toDBQuery the toDBQuery to set
     */
    public void setToDBQuery(String toDBQuery) {
        this.toDBQuery = toDBQuery;
    }

    /**
     * @return the value
     */
    public String getValue() {
        return value;
    }

    /**
     * @param value the value to set
     */
    public void setValue(String value) {
        this.setValueSet(true);
        this.value = value;
    }

    /**
     * @return the iterationRowSingleFromDBQuery
     */
    public String getIterationRowSingleFromDBQuery() {
        return iterationRowSingleFromDBQuery;
    }

    /**
     * @param iterationRowSingleFromDBQuery the iterationRowSingleFromDBQuery to set
     */
    public void setIterationRowSingleFromDBQuery(String iterationRowSingleFromDBQuery) {
        this.iterationRowSingleFromDBQuery = iterationRowSingleFromDBQuery;
    }

    /**
     * @return the defaultValue
     */
    public String getDefaultValue() {
        return defaultValue;
    }

    /**
     * @param defaultValue the defaultValue to set
     */
    public void setDefaultValue(String defaultValue) {
        this.defaultValue = defaultValue;
    }

    /**
     * @return the valueSet
     */
    public boolean isValueSet() {
        return valueSet;
    }

    /**
     * @param valueSet the valueSet to set
     */
    public void setValueSet(boolean valueSet) {
        this.valueSet = valueSet;
    }
}
